package com.nearbymap.model;

import java.util.List;

public class DirectionsResponse {

	public static final String XPATH_OVERVIEW_POLYLINE = "//overview_polyline/points";
	private XmlResponse xmlResponse;

	public DirectionsResponse() {
		xmlResponse = new XmlResponse();
	}
	public DirectionsResponse(String responseXml) {
		xmlResponse = new XmlResponse();
		xmlResponse.setResponseXml(responseXml);
	}
	public DirectionsResponse(XmlResponse xmlResponse) {
		this.xmlResponse = xmlResponse;
	}
	
	public String getOverviewPolyline() {
		List<String> list = xmlResponse.getTextAt(XPATH_OVERVIEW_POLYLINE);
		if(list.size() == 1) {
			return list.get(0);
		} else {
			throw new RuntimeException("Bad OverviewPolylines size: " + list.size());
		}
	}

	public List<String> getTextAt(String xpathPattern) {
		return xmlResponse.getTextAt(xpathPattern);
	}
}
